package com.example.mybatisplusdemo.common;

import lombok.Data;

@Data
public class Result {
    private  int code;
    private String msg;
    private Long total;
    private Object data;
    //失败
    public static Result fail(){
        return result(400,"Fail!",0L,null);
    }
    public static Result fail(int code){
        return result(code,"Fail!",0L,null);
    }

    //成功！
    public static Result suc(){
        return result(200,"成功Win！",0L,null);
    }
    public static Result suc(Object data){
        return result(200,"成功Win！",0L,data);
    }
    public static Result suc(Object data,Long total){
        return result(200,"成功Win！",total,data);
    }
    public static Result suc(String msg,Object data,Long total){
        return result(200,msg,total,data);
    }
    private static Result result(int code,String msg,Long total,Object data) {
        Result result = new Result();
        result.setData(data);
        result.setMsg(msg);
        result.setCode(code);
        result.setTotal(total);
        return result;
    }
}
